package com.example.toolbar;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.example.toolbar.databinding.ActivityMainBinding;
import com.example.toolbar.toolbar.Toolbar1Activity;
import com.example.toolbar.toolbar.Toolbar2Activity;
import com.example.toolbar.toolbar.Toolbar3Activity;
import com.example.toolbar.toolbar.Toolbar4Activity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private ActivityMainBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        initView();
    }

    private void initView() {
        binding.toolbar1.setOnClickListener(this);
        binding.toolbar2.setOnClickListener(this);
        binding.toolbar3.setOnClickListener(this);
        binding.toolbar4.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Intent intent = null;
        switch (v.getId()) {
            case R.id.toolbar1:
                intent = new Intent(MainActivity.this, Toolbar1Activity.class);
                break;
            case R.id.toolbar2:
                intent = new Intent(MainActivity.this, Toolbar2Activity.class);
                break;
            case R.id.toolbar3:
                intent = new Intent(MainActivity.this, Toolbar3Activity.class);
                break;
            case R.id.toolbar4:
                intent = new Intent(MainActivity.this, Toolbar4Activity.class);
                break;
        }
        startActivity(intent);
    }
}
